package org.example.seat_management.Service.Impl;

import org.example.seat_management.Entity.ClassInfo;
import org.example.seat_management.Mapper.ClassInfoMapper;
import org.example.seat_management.Service.ClassService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class ClassServiceImpl implements ClassService {

    private final ClassInfoMapper classInfoMapper;

    public ClassServiceImpl(ClassInfoMapper classInfoMapper) {
        this.classInfoMapper = classInfoMapper;
    }

    @Override
    @Transactional
    public Long create(ClassInfo classInfo) {
        classInfoMapper.insert(classInfo);
        return classInfo.getId();
    }

    @Override
    @Transactional
    public void update(ClassInfo classInfo) {
        classInfoMapper.update(classInfo);
    }

    @Override
    @Transactional
    public void delete(Long id) {
        classInfoMapper.softDelete(id);
    }

    @Override
    public ClassInfo getById(Long id) {
        return classInfoMapper.findById(id);
    }

    @Override
    public List<ClassInfo> listAll() {
        return classInfoMapper.findAll();
    }
}


